home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / aijournl / 1986_11 / aiapp.nov < prev    next >
Text File  |  1986-09-25  |  39KB  |  1,132 lines

  1.  
  2.  
  3.                           AI Apprentice
  4.                 by Bill Thompson and Bev Thompson
  5.                      November 1986 AI EXPERT
  6.  
  7.  
  8.                             TREES.KB
  9.                          Knowledge Base
  10.  
  11. 1
  12. if stocking good is yes
  13. and avg < 5 is yes
  14. and 2000 + per acre is yes
  15. then weed or clean is yes
  16. and branch 8 is yes .
  17.  
  18. prompt stocking good
  19. Is the stocking of the jack pine stand currently at least minimum ?
  20.  
  21. If you are unsure of how to determine stocking see page 4 in the
  22. Mangagers Handbook for Jack Pine.
  23. .
  24.  
  25. trans stocking good
  26. the jack pine stocking in the area is /not/ minimum or higher
  27. .
  28.  
  29. prompt avg < 5
  30. Is the average diameter of the trees less than 5 inches ?
  31. .
  32.  
  33. trans avg < 5
  34. the average is /not/ < 5 inches
  35. .
  36.  
  37. prompt 2000 + per acre
  38. Are there 2000 or more trees per acre ?
  39. .
  40.  
  41. trans 2000 + per acre
  42. there are /not/ at least 2000 trees per acre
  43. .
  44.  
  45. trans weed or clean
  46. the stand of jack pine must /not/ be weeded and cleaned
  47. .
  48.  
  49. 2
  50. if stocking good is yes
  51. and avg < 5 is yes
  52. and 2000 + per acre is no
  53. then branch 8 is yes .
  54.  
  55. 3
  56. if stocking good is yes
  57. and avg < 5 is no
  58. and age is mature
  59. then branch 9 is no
  60. and branch 11 is yes .
  61.  
  62. prompt age
  63. Is the age of the stand mature or immature ?
  64. .
  65.  
  66. trans age
  67. the age of the stand
  68. .
  69.  
  70. 4
  71. if stocking good is yes
  72. and avg < 5 is no
  73. and age is immature
  74. and site index > 60 is yes
  75. and product size is large
  76. and 120 + basal area is yes
  77. then thin the area is yes
  78. and branch 9 is yes .
  79.  
  80. prompt site index > 60
  81. Is the site index greater than 60 ?
  82. .
  83.  
  84. prompt product size
  85. Do you want to manage the timber for large or small products ?
  86. .
  87.  
  88. prompt 120 + basal area
  89. Is the basal area per acre at least 120 square feet ?
  90. .
  91.  
  92. trans thin the area
  93. It is /not/ important to thin the area
  94. .
  95.  
  96. 5
  97. if stocking good is yes
  98. and avg < 5 is no
  99. and age is immature
  100. and site index > 60 is yes
  101. and product size is large
  102. and 120 + basal area is no
  103. then branch 9 is yes .
  104.  
  105. 6
  106. if stocking good is yes
  107. and avg < 5 is no
  108. and age is immature
  109. and site index > 60 is yes
  110. and product size is large
  111. then branch 9 is yes .
  112.  
  113. 7
  114. if stocking good is yes
  115. and avg < 5 is no
  116. and age is immature
  117. and site index > 60 is no
  118. then branch 9 is yes .
  119.  
  120. 8
  121. if stocking good is no
  122. and other resources is yes
  123. then maintain is yes
  124. and recommend is maintain .
  125.  
  126. prompt other resources
  127. Do you want to maintain this condition to support other resources ?
  128. .
  129.  
  130. trans other resources
  131. it is /not/ necessary to maintain the present condition for other resources
  132. .
  133.  
  134. trans maintain
  135. you should /not/ maintain the stand in its present condition
  136. .
  137.  
  138. 9
  139. if stocking good is no
  140. and other resources is no
  141. then branch 11 is yes .
  142.  
  143. 10
  144. if branch 8 is yes
  145. and severe competition is yes
  146. then release is yes
  147. and branch 9 is yes .
  148.  
  149. prompt severe competition
  150. Is there severe overstory competition ?
  151. .
  152.  
  153. trans severe competition
  154. there is /not/ severe overstory competition
  155. .
  156.  
  157. trans release
  158. Competing trees should /not/ be eliminated
  159. .
  160.  
  161. 11
  162. if branch 8 is yes
  163. and severe competition is no
  164. then branch 9 is yes .
  165.  
  166. 12
  167. if branch 9 is yes
  168. and high risk is yes
  169. then control if feasible is yes
  170. and recommend is control if feasible .
  171.  
  172. prompt high risk
  173. Is there a high risk of injury or loss ?
  174. .
  175.  
  176. trans high risk
  177. there is /not/ a high risk of injury or loss
  178. .
  179.  
  180. trans control if feasible
  181. the current area should /not/ be controlled if that is at all feasible
  182. .
  183.  
  184. 13
  185. if branch 9 is yes
  186. and high risk is no
  187. then wait is yes
  188. and recommend is wait .
  189.  
  190. trans wait
  191. You should /not/ wait before doing anything else to this stand
  192. .
  193.  
  194. 14
  195. if branch 11 is yes
  196. and pine desired is yes
  197. and pine suited is yes
  198. and desirable seed is yes
  199. and serotinous cones is yes
  200. and 10/acre adequate is yes
  201. and burning planned is yes
  202. then use seed tree is yes
  203. and recommend is use seed tree .
  204.  
  205. prompt pine desired
  206. Do you want to keep jack pine in this area ?
  207. .
  208.  
  209. trans pine desired
  210. Jack pine is /not/ wanted in the area
  211. .
  212.  
  213. prompt pine suited
  214. Is jack pine well suited to this site ?
  215. .
  216.  
  217. trans pine suited
  218. the area is /not/ well suited to jack pine
  219. .
  220.  
  221. prompt desirable seed
  222. Is there a desirable jack pine seed source on the area ?
  223. .
  224.  
  225. trans desirable seed
  226. there is /not/ a desirable seed source on the area
  227. .
  228.  
  229. prompt serotinous cones
  230. Do the trees on the site have serotinous cones ?
  231. .
  232.  
  233. trans serotinous cones
  234. there is /not/ a supply of serotinous cones
  235. .
  236.  
  237. prompt 10/acre adequate
  238. Are 10 trees per acre adequate to seed the area ?
  239. .
  240.  
  241. trans 10/acre adequate
  242. 10 per acre is /not/ adequate
  243. .
  244.  
  245. prompt burning planned
  246. Has a prescribed burning been planned ?
  247. .
  248.  
  249. trans burning planned
  250. burning is /not/ planned
  251. .
  252.  
  253. trans use seed tree
  254. You should /not/ use seed trees to seed the area
  255. .
  256.  
  257. 15
  258. if branch 11 is yes
  259. and pine desired is yes
  260. and pine suited is yes
  261. and desirable seed is yes
  262. and serotinous cones is yes
  263. and 10/acre adequate is yes
  264. and burning planned is no
  265. then silviculture method is clearcut
  266. and branch 17 is yes .
  267.  
  268. trans silvaculture method
  269. the best silviculture method to use
  270. .
  271.  
  272. 16
  273. if branch 11 is yes
  274. and pine desired is yes
  275. and pine suited is yes
  276. and desirable seed is yes
  277. and serotinous cones is yes
  278. and 10/acre adequate is no
  279. then silviculture method is clearcut
  280. and branch 17 is yes .
  281.  
  282. 17
  283. if branch 11 is yes
  284. and pine desired is yes
  285. and pine suited is yes
  286. and desirable seed is yes
  287. and serotinous cones is no
  288. and two harvests wanted is yes
  289. and two harvests possible is yes
  290. then silviculture method is shelterwood
  291. and branch 17 is yes .
  292.  
  293. prompt two harvests wanted
  294. Do you want to do two commercial harvests on this area ?
  295. .
  296.  
  297. trans two harvests wanted
  298. two commercial harvests are /not/ wanted
  299. .
  300.  
  301. prompt two harvests possible
  302. Is it possible to get two harvests from this area ?
  303. .
  304.  
  305. trans two harvests possible
  306. two harvests can /not/ be done on this area
  307. .
  308.  
  309. 18
  310. if branch 11 is yes
  311. and pine desired is yes
  312. and pine suited is yes
  313. and desirable seed is yes
  314. and serotinous cones is no
  315. and two harvests wanted is yes
  316. and two harvests possible is no
  317. then silviculture method is clearcut
  318. and branch 17 is yes .
  319.  
  320. 19
  321. if branch 11 is yes
  322. and pine desired is yes
  323. and pine suited is yes
  324. and desirable seed is yes
  325. and serotinous cones is no
  326. and two harvests wanted is no
  327. then silviculture method is clearcut
  328. and branch 17 is yes .
  329.  
  330. 20
  331. if branch 11 is yes
  332. and pine desired is yes
  333. and pine suited is yes
  334. and desirable seed is no
  335. then silviculture method is clearcut
  336. and branch 17 is yes .
  337.  
  338. 21
  339. if branch 11 is yes
  340. and pine desired is yes
  341. and pine suited is no
  342. then convert is yes
  343. and recommend is convert .
  344.  
  345. trans convert
  346. you should /not/ convert the area to some more desirable kind of tree
  347. .
  348.  
  349. 22
  350. if branch 11 is yes
  351. and pine desired is no
  352. then convert is yes
  353. and recommend is convert .
  354.  
  355.  
  356. 26
  357. if branch 17 is yes
  358. and adequate seedbed is yes
  359. then branch 18 is yes .
  360.  
  361. prompt adequate seedbed
  362. Is there an adequate seedbed for planting ?
  363. .
  364.  
  365. trans adequate seedbed
  366. there is /not/ an adequate seedbed for planting
  367. .
  368.  
  369. 27
  370. if branch 17 is yes
  371. and adequate seedbed is no
  372. then prepare site is yes
  373. and branch 18 is yes .
  374.  
  375. trans prepare site
  376. the site should /not/ be prepared before planting
  377. .
  378.  
  379. 28
  380. if branch 18 is yes
  381. and silviculture method is shelterwood
  382. then use natural seeding is yes
  383. and recommend is use natural seeding .
  384.  
  385. trans use natural seeding
  386. natural seeding techniques should /not/ be used
  387. .
  388.  
  389. 29
  390. if branch 18 is yes
  391. and silviculture method is clearcut
  392. and improved stock is yes
  393. then plant is yes
  394. and recommend is plant .
  395.  
  396. prompt improved stock
  397. Is there improved planting stock available ?
  398. .
  399.  
  400. trans improved stock
  401. there is /not/ improved stock available
  402. .
  403.  
  404. trans plant
  405. since there is better stock available you can /not/ plant using that stock
  406. .
  407.  
  408. 30
  409. if branch 18 is yes
  410. and silviculture method is clearcut
  411. and improved stock is no
  412. and good cone supply is yes
  413. then scatter cones is yes
  414. and recommend is scatter cones .
  415.  
  416. prompt good cone supply
  417. Is there a good supply of serotinous cones on the area ?
  418. .
  419.  
  420. trans good cone supply
  421. there is /not/ a good cone supply
  422. .
  423.  
  424. trans scatter cones
  425. you should /not/ scatter the supply of serotinous cones over the area
  426. .
  427.  
  428. 31
  429. if branch 18 is yes
  430. and silviculture method is clearcut
  431. and improved stock is no
  432. and good cone supply is no
  433. then direct seed is yes
  434. and recommend is direct seed .
  435.  
  436. trans direct seed
  437. Since the cone supply is inadequate, you should /not/ directly seed the
  438. area
  439. .
  440.  
  441.  
  442. -------------------------------------------------------------------------
  443.  
  444. The following comments are not a part of the knowledge base.  If you
  445. try to run the knowledge base this part of the file should be removed
  446.  
  447.  
  448. Abbreviated KEY
  449.  
  450. 1.  stocking good is yes ............................. 2
  451. 1.  stocking good is no  ............................. 10
  452.     2. avg < 5 is yes ................................ 3
  453.     2. avg < 5 is no ................................. 4
  454. 3.  2000 + per acre is yes ..........WEED OR CLEAN.... 8
  455. 3.  2000 + per acre is no ............................ 8
  456.     4. age is mature ................................. 11
  457.     4. age is immature ............................... 5
  458. 5.  site index > 60 is yes ........................... 6
  459. 5.  site index > 60 is no ............................ 9
  460.     6. product size is large ......................... 7
  461.     6. product size is small ......................... 9
  462. 7.  120 + basal area is yes .........THIN............. 9
  463. 7.  120 + basal area is no ........................... 9
  464.     8. severe competition is yes ....RELEASE.......... 9
  465.     8. severe competition is no ...................... 9
  466. 9.  high risk is yes ................................. CONTROL IF FEASIBLE
  467. 9.  high risk is no .................................. WAIT
  468.     10. other resources is yes ....................... MAINTAIN
  469.     10. other resources is no ........................ 11
  470. 11. pine suitable is yes ............................. 12
  471. 11. pine suitable is no .............................. CONVERT
  472.     12. desirable seed is yes ........................ 13
  473.     12. desirable seed is no ........USE CLEARCUT..... 17
  474. 13. serotinous cones is yes .......................... 14
  475. 13. serotinous cones is no ........................... 16
  476.     14. 10/acre adequate is yes ...................... 15
  477.     14. 10/acre adequate is no ......USE CLEARCUT..... 17
  478. 15. burning planned is yes ........................... USE SEED TREE
  479. 15. burning planned is no ...........USE CLEARCUT..... 17
  480.     16. two harvests wanted is yes ..USE SHELTERWOOD.. 17
  481.     16. two harvests wanted is no ...USE CLEARCUT..... 17
  482. 17. adequate seedbeds is yes ......................... 18
  483. 17. adequate seedbeds is no .........PREPARE SITE..... 18
  484.     18. silviculture method is shelterwood ........... USE NATURAL SEEDING
  485.     18. silviculture method is clearcut .............. 19
  486. 19. improved stock is yes ............................ PLANT
  487. 19. improved stock is no ............................. 20
  488.     20. good cone supply is yes ...................... SCATTER CONES
  489.     20. good cone supply is no ....................... DIRECT SEED
  490.  
  491.  
  492.  
  493. The purpose of this exercise is to show how a knowledge base can be
  494. designed to directly follow a key.  There are several places where the
  495. KB could have been made more efficient, but this would have meant
  496. departing from the order of the key.  You might find it an interesting
  497. exercise to explore other ways this same information could have been
  498. represented in the KB.
  499.  
  500. The key appears in the Managers Handbood for Jack Pine in the North Central
  501. States.  The Handbook was produced by the North Central Forest Experiment
  502. Station of the Forest Service of the U.S. Dept. of Agriculture.  Our
  503. intention in writing this knowledge base is to show the structure of a
  504. knowledge base written for a backward chaining inference engine directly
  505. from an existing document.  If this KB were to be actually used, it would
  506. need to have clearer questions and more explanations to the user.  These
  507. explanations are provided in the handbook and could be easily incorporated
  508. into the knowledge base.
  509.  
  510. The knowledge base will run on the expert system shell MicroExpert which is
  511. an example of a backward chaining inference engine. MicroExpert is
  512. available from McGraw-Hill for $49.95 and can be ordered by calling 1-800-
  513. 628-0004 or, in NY, 212-512-2999 . The knowledge base is described in the
  514. column AI Apprentice which appears in the November issue of AI Expert
  515. magazine.  The design details of the inference engine which runs the KB is
  516. described in the article "Inside an Expert System" in the April 1985
  517. isuue of BYTE magazine.
  518.  
  519. MicroExpert, AI Apprentice and "Inside an Expert System" are all written
  520. by Bev and Bill Thompson . We're always happy to hear about your thoughts
  521. and comments, good or bad on any of our work.  Contact us at the address
  522. below, on Compuserve or BIX. Our Compuserve id is 76703,4324 and we can be
  523. reached by Easyplex or in the AI Expert Forum.  Our BIX id is bbt and  we
  524. may  be  contacted via BIXmail or by leaving comments in the  MicroExpert
  525. conference.
  526.  
  527. Bill and Bev Thompson
  528. R.D. 2 Box 430
  529. Nassau, N.Y.  12123
  530.  
  531.  
  532.                             TREES.PRO
  533.                          PROLOG program 
  534.  
  535.  
  536. /* This PDPROLOG program implements a knowledge base based upon the
  537.    following key:
  538.  
  539.    To run the program type "go."
  540.    Caution - This program can be very S L O W.
  541.  
  542. Abbreviated KEY
  543.  
  544. 1.  stocking good is yes ............................. 2
  545. 1.  stocking good is no  ............................. 10
  546.     2. avg < 5 is yes ................................ 3
  547.     2. avg < 5 is no ................................. 4
  548. 3.  2000 + per acre is yes ..........WEED OR CLEAN.... 8
  549. 3.  2000 + per acre is no ............................ 8
  550.     4. age is mature ................................. 11
  551.     4. age is immature ............................... 5
  552. 5.  site index > 60 is yes ........................... 6
  553. 5.  site index > 60 is no ............................ 9
  554.     6. product size is large ......................... 7
  555.     6. product size is small ......................... 9
  556. 7.  120 + basal area is yes .........THIN............. 9
  557. 7.  120 + basal area is no ........................... 9
  558.     8. severe competition is yes ....RELEASE.......... 9
  559.     8. severe competition is no ...................... 9
  560. 9.  high risk is yes ................................. CONTROL IF FEASIBLE
  561. 9.  high risk is no .................................. WAIT
  562.     10. other resources is yes ....................... MAINTAIN
  563.     10. other resources is no ........................ 11
  564. 11. pine suitable is yes ............................. 12
  565. 11. pine suitable is no .............................. CONVERT
  566.     12. desirable seed is yes ........................ 13
  567.     12. desirable seed is no ........USE CLEARCUT..... 17
  568. 13. serotinous cones is yes .......................... 14
  569. 13. serotinous cones is no ........................... 16
  570.     14. 10/acre adequate is yes ...................... 15
  571.     14. 10/acre adequate is no ......USE CLEARCUT..... 17
  572. 15. burning planned is yes ........................... USE SEED TREE
  573. 15. burning planned is no ...........USE CLEARCUT..... 17
  574.     16. two harvests wanted is yes ..USE SHELTERWOOD.. 17
  575.     16. two harvests wanted is no ...USE CLEARCUT..... 17
  576. 17. adequate seedbeds is yes ......................... 18
  577. 17. adequate seedbeds is no .........PREPARE SITE..... 18
  578.     18. silviculture method is shelterwood ........... USE NATURAL SEEDING
  579.     18. silviculture method is clearcut .............. 19
  580. 19. improved stock is yes ............................ PLANT
  581. 19. improved stock is no ............................. 20
  582.     20. good cone supply is yes ...................... SCATTER CONES
  583.     20. good cone supply is no ....................... DIRECT SEED
  584.  
  585.  
  586.  
  587. The purpose of this exercise is to show how an expert system can be
  588. designed to directly follow a key.  There are several places where the
  589. program could have been made more efficient, but this would have meant
  590. departing from the order of the key.  You might find it an interesting
  591. exercise to explore other ways this same information could have been
  592. represented in the program.
  593.  
  594. The key appears in the Managers Handbood for Jack Pine in the North Central
  595. States.  The Handbook was produced by the North Central Forest Experiment
  596. Station of the Forest Service of the U.S. Dept. of Agriculture.  Our
  597. intention in writing this knowledge base is to show the structure of a
  598. knowledge base written for a backward chaining inference engine directly
  599. from an existing document.  If this KB were to be actually used, it would
  600. need to have clearer questions and more explanations to the user.  These
  601. explanations are provided in the handbook and could be easily incorporated
  602. into the knowledge base.
  603.  
  604. This program is similar to the KB for the expert system shell
  605. MicroExpert which is an example of a backward chaining inference engine.
  606. MicroExpert is available from McGraw-Hill for $49.95 and can be ordered
  607. by calling 1-800-628-0004 or, in NY, 212-512-2999 .
  608. The knowledge base is described in the AI Apprentice column which appears
  609. in the November issue of AI Expert magazine.
  610. The design details of the inference engine which runs the KB is
  611. described in the article "Inside an Expert System" in the April 1985
  612. isuue of BYTE magazine.
  613.  
  614. MicroExpert, AI Apprentice and "Inside an Expert System" are all written
  615. by Bev and Bill Thompson . We're always happy to hear about your thoughts
  616. and comments, good or bad on any of our work.  Contact us at the address
  617. below, on Compuserve or BIX. Our Compuserve id is 76703,4324 and we can be
  618. reached by Easyplex or in the AI Expert Forum.  Our BIX id is bbt and  we
  619. may  be  contacted via BIXmail or by leaving comments in the  MicroExpert
  620. conference.
  621.  
  622. Bill and Bev Thompson
  623. R.D. 2 Box 430
  624. Nassau, N.Y.  12123      */
  625.  
  626. /* Control - In MicroExpert terms, the goal of the consultation is
  627.    recommendation */
  628.  
  629. go :- clear_kb,
  630.       give_advice.
  631. give_advice :- recommendation(X),
  632.                fail.
  633. give_advice :- print_advice.
  634.  
  635. /* The rules -
  636.    These are implemented this way to mimic the MicroExpert rule set.
  637.    Looking at them side by side should show the similarities. */
  638.  
  639. fact(branch8,yes) :- fact('stocking good',yes),
  640.                      fact('avg < 5',yes),
  641.                      fact('2000+ per acre',yes),
  642.                      recommend('The stand of jack pine must be weeded and cleaned.').
  643. fact(branch8,yes) :- fact('stocking good',yes),
  644.                      fact('avg < 5',yes),
  645.                      fact('2000+ per acre',no).
  646. fact(branch9,no) :- fact('stocking good',yes),
  647.                     fact('avg < 5',no),
  648.                     fact(age,mature),
  649.                     assertz(fact(branch11,yes)).
  650. fact(branch11,yes) :- fact('stocking good',yes),
  651.                       fact('avg < 5',no),
  652.                       fact(age,mature),
  653.                       assertz(fact(branch9,no)).
  654. fact(branch9,yes) :- fact('stocking good',yes),
  655.                      fact('avg < 5',no),
  656.                      fact(age,immature),
  657.                      fact('site index > 60',yes),
  658.                      fact('product size',large),
  659.                      fact('120+ basal area',yes),
  660.                      recommend('It is important to thin the area').
  661. fact(branch9,yes) :- fact('stocking good',yes),
  662.                      fact('avg < 5',no),
  663.                      fact(age,immature),
  664.                      fact('site index > 60',yes),
  665.                      fact('product size',large),
  666.                      fact('120+ basal area',no).
  667. fact(branch9,yes) :- fact('stocking good',yes),
  668.                      fact('avg < 5',no),
  669.                      fact(age,immature),
  670.                      fact('site index > 60',yes),
  671.                      fact('product size',large).
  672. fact(branch9,yes) :- fact('stocking good',yes),
  673.                      fact('avg < 5',no),
  674.                      fact(age,immature),
  675.                      fact('site index > 60',yes).
  676. recommendation(maintain) :-
  677.        fact('stocking good',no),
  678.        fact('other resources',yes),
  679.        recommend('You should maintain the stand in its present condition').
  680. fact(branch11,yes) :- fact('stocking good',no),
  681.                       fact('other resources',no).
  682. fact(branch9,yes) :- fact(branch8,yes),
  683.                      fact('severe competition',yes),
  684.                      recommend('Competing trees should be eliminated.').
  685. fact(branch9,yes) :- fact(branch8,yes),
  686.                      fact('severe competition',no).
  687. recommendation(control) :-
  688.         fact(branch9,yes),
  689.         fact('high risk',yes),
  690.         recommend('The current area should be controlled, if at all feasible.').
  691. recommendation(wait) :-
  692.         fact(branch9,yes),
  693.         fact('high risk',no),
  694.         recommend('You should wait before doing anything else to this stand.').
  695. recommendation('use seed tree') :-
  696.         fact(branch11,yes),
  697.         fact('pine desired',yes),
  698.         fact('pine suited',yes),
  699.         fact('desirable seed',yes),
  700.         fact('serotinous cones',yes),
  701.         fact('10/acres adequate',yes),
  702.         fact('burning planned',yes),
  703.         recommend('You should use seed trees to seed the area.').
  704. fact(branch17,yes) :-
  705.             fact(branch11,yes),
  706.             fact('pine desired',yes),
  707.             fact('pine suited',yes),
  708.             fact('desirable seed',yes),
  709.             fact('serotinous cones',yes),
  710.             fact('10/acres adequate',yes),
  711.             fact('burning planned',no),
  712.             add_fact(silvaculture,clearcut),
  713.             recommend('The best silvaculture method to use is clearcut.').
  714. fact(branch17,yes) :-
  715.         fact(branch11,yes),
  716.         fact('pine desired',yes),
  717.         fact('pine suited',yes),
  718.         fact('desirable seed',yes),
  719.         fact('serotinous cones',yes),
  720.         fact('10/acres adequate',no),
  721.         add_fact(silvaculture,clearcut),
  722.         recommend('The best silvaculture method to use is clearcut.').
  723. fact(branch17,yes) :-
  724.         fact(branch11,yes),
  725.         fact('pine desired',yes),
  726.         fact('pine suited',yes),
  727.         fact('desirable seed',yes),
  728.         fact('serotinous cones',no),
  729.         fact('two harvests wanted',yes),
  730.         fact('two harvests possible',yes),
  731.         add_fact(silvaculture,shelterwood),
  732.         recommend('The best silvaculture method to use is the shlterwood method.').
  733. fact(branch17,yes) :-
  734.         fact(branch11,yes),
  735.         fact('pine desired',yes),
  736.         fact('pine suited',yes),
  737.         fact('desirable seed',yes),
  738.         fact('serotinous cones',no),
  739.         fact('two harvests wanted',yes),
  740.         fact('two harvests possible',no),
  741.         add_fact(silvaculture,clearcut),
  742.         recommend('The best silvaculture method to use is clearcut.').
  743. fact(branch17,yes) :-
  744.         fact(branch11,yes),
  745.         fact('pine desired',yes),
  746.         fact('pine suited',yes),
  747.         fact('desirable seed',yes),
  748.         fact('serotinous cones',no),
  749.         fact('two harvests wanted',no),
  750.         add_fact(silvaculture,clearcut),
  751.         recommend('The best silvaculture method to use is clearcut.').
  752. fact(branch17,yes) :-
  753.         fact(branch11,yes),
  754.         fact('pine desired',yes),
  755.         fact('pine suited',yes),
  756.         fact('desirable seed',no),
  757.         add_fact(silvaculture,clearcut),
  758.         recommend('The best silvaculture method to use is clearcut.').
  759. recommendation(convert) :-
  760.         fact(branch11,yes),
  761.         fact('pine desired',yes),
  762.         fact('pine suited',no),
  763.         recommend('You should convert the area to some more desirable kind of tree.').
  764. recommendation(convert) :-
  765.         fact(branch11,yes),
  766.         fact('pine desired',no),
  767.         recommend('You should convert the area to some more desirable kind of tree.').
  768. fact(branch18,yes) :-
  769.         fact(branch17,yes),
  770.         fact('adequate seedbed',yes).
  771. fact(branch18,yes) :-
  772.         fact(branch17,yes),
  773.         fact('adequate seedbed',no),
  774.         recommend('The site should be prepared before planting.').
  775. recommendation('natural seeding') :-
  776.         fact(branch18,yes),
  777.         fact(silvaculture,shelterwood),
  778.         recommend('The natural seeding technique should be used.').
  779. recommendation(plant) :-
  780.         fact(branch18,yes),
  781.         fact(silvaculture,clearcut),
  782.         fact('improved stock',yes),
  783.         recommend('Since there is better stock available, you can plant using that stock.').
  784. recommendation('scatter cones') :-
  785.         fact(branch18,yes),
  786.         fact(silvaculture,clearcut),
  787.         fact('improved stock',no),
  788.         fact('good cone supply',yes),
  789.         recommend('You should scatter the serotinous cones over the area.').
  790. recommendation('direct seed') :-
  791.         fact(branch18,yes),
  792.         fact(silvaculture,clearcut),
  793.         fact('improved stock',no),
  794.         fact('good cone supply',no),
  795.         recommend('You should directly seed the area.').
  796.  
  797. /* These routines add new facts to the internal knowledge base - kb */
  798.  
  799. fact(X,Y) :- kb(X,Y),! .
  800. fact(X,Y) :- not(kb(X,Anything)),
  801.              question(X,Answer),
  802.              assertz(kb(X,Answer)),
  803.              Y = Answer.
  804.  
  805. add_fact(X,Y) :- kb(X,Y),!.
  806. add_fact(X,Y) :- assertz(kb(X,Y)).
  807.  
  808. recommend(X) :- add_fact(advice,X).
  809.  
  810. /* Questions to ask the user */
  811.  
  812. question('stocking good',Ans) :-
  813.         print('Is the stocking of the jack pine stand currently'),nl,
  814.         print('at least minimum ? '),nl,nl,
  815.         print('If you are unsure of how to determine stocking,'),nl,
  816.         print('see page 4 in the Managers Handbook for Jack Pine'),
  817.         nl,
  818.         ask('',Ans,[ yes , no ]).
  819. question('avg < 5',Ans) :-
  820.         ask('Is the average diameter of the trees less than 5 inches ?',
  821.              Ans,[yes,no]).
  822. question('2000+ per acre',Ans) :-
  823.         ask('Are there 2000 or more trees per acre ?',Ans,[yes,no]).
  824. question(age,Ans) :-
  825.         ask('Is the age of the stand mature or immature ?',
  826.              Ans,[mature,immature]).
  827. question('site index > 60',Ans) :-
  828.         ask('Is the site index greater than 60 ?',Ans,[yes,no]).
  829. question('product size',Ans) :-
  830.         ask('Do you want to manage the timber for large or small products ?',
  831.             Ans,[large,small]).
  832. question('120+ basal area',Ans) :-
  833.         ask('Is the basal area per acre at least 120 square feet ?',
  834.             Ans,[yes,no]).
  835. question('other resources',Ans) :-
  836.         ask('Do you want to maintain this condition to support other resources?',
  837.              Ans,[yes,no]).
  838. question('severe competition',Ans) :-
  839.         ask('Is there severe overstory competition ?',Ans,[yes,no]).
  840. question('high risk',Ans) :-
  841.         ask('Is there a high risk of loss or injury ?',Ans,[yes,no]).
  842. question('pine desired',Ans) :-
  843.         ask('Do you want to keep jack pine in this area ?',Ans,[yes,no]).
  844. question('pine suited',Ans) :-
  845.         ask('Is jack pine well suited to this site ?',Ans,[yes,no]).
  846. question('desirable seed',Ans) :-
  847.         ask('Is there a desirable jack pine seed source on the area ?',
  848.              Ans,[yes,no]).
  849. question('serotinous cones',Ans) :-
  850.         ask('Do the trees on the site have serotinous cones ?',Ans,[yes,no]).
  851. question('10/acres adequate',Ans) :-
  852.         ask('Are 10 trees per acre adequate to seed the area ?',Ans,[yes,no]).
  853. question('burning planned',Ans) :-
  854.         ask('Has a prescribed burning been planned ?',Ans,[yes,no]).
  855. question('two harvests wanted',Ans) :-
  856.         ask('Do you want two commercial harvests on this area ?',Ans,[yes,no]).
  857. question('two harvests possible',Ans) :-
  858.         ask('Is it possible to get two harvests from this area ?',Ans,[yes,no]).
  859. question('adequate seedbed',Ans) :-
  860.         ask('Is there an adequate seedbed for planting ?',Ans,[yes,no]).
  861. question('improved stock',Ans) :-
  862.         ask('Is there an improved planting stock available ?',Ans,[yes,no]).
  863. question('good cone supply',Ans) :-
  864.         ask('Is there a good supply of serotinous cones in the area ?',
  865.              Ans,[yes,no]).
  866.  
  867. /* Utility Routines - to be useful, we should add some routines to allow
  868.                        the user to ask "How" and "Why" */
  869.  
  870. display_kb :- kb(X,Y),
  871.               print(X,' is ',Y),
  872.               nl,
  873.               fail.
  874. display_kb.
  875.  
  876.  
  877. print_advice :-
  878.     nl,nl,
  879.     print('Based upon your responses, the following is recommended :'),nl,nl,
  880.     show_advice.
  881. show_advice :-
  882.     kb(advice,X),
  883.     print(X),
  884.     nl,
  885.     fail.
  886. show_advice :-
  887.     nl,print('To see the complete set of derived facts,'),
  888.     print('type "display_kb."').
  889.  
  890.  
  891. clear_kb :- retract(kb(_,_)),
  892.             fail .
  893. clear_kb.
  894.  
  895. member(X,[X|_]).
  896. member(X,[_|Y]) :- member(X,Y).
  897.  
  898. ask(Ques,Ans,LegalResponses) :-
  899.     nl,print(Ques,' '),
  900.     read(Ans),
  901.     member(Ans,LegalResponses),!.
  902. ask(Ques,Ans,LegalResponses) :-
  903.    nl,nl,nl,
  904.    print('Please respond with : ',LegalResponses),nl,nl,
  905.    ask(Ques,Ans,LegalResponses).
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.                       Listings and Figures
  914.                   printed in AI EXPERT magazine
  915.  
  916.  
  917. 1.  Jack pine stand with minimum or higher stocking .................. 2
  918. 1.  Jack pine stand with less than minimum stocking .................. 10
  919.  
  920.     2.  Average tree diameter less than 5 inches ..................... 3
  921.     2.  Average tree diameter 5 inches or more ....................... 4
  922.  
  923. 3.  2,000 or more trees per acre ..................WEED OR CLEAN ..... 8
  924. 3.  Less than 2,000 trees per acre ................................... 8
  925.  
  926.     4.  Stand is mature .............................................. 11
  927.     4.  Stand is not mature .......................................... 5
  928.  
  929. Figure 1 - Key for forest management taken from USDA Forest Service
  930.            Handbook
  931.  
  932.  
  933.  
  934.  
  935.                                                         |-- yes ===> weed or clean
  936.                                                         |            and do # 8
  937.                              |-- yes --- 2000+ per acre-|
  938.                              |                          |-- no ===> do # 8
  939.          |-- yes -- diameter-|
  940.          |          < 5 in.  |             |-- mature ===> do # 11
  941. minimum  |                   |-- no -- age-|
  942. stocking-|                                 |-- young ===> do # 5
  943.          |
  944.          |                  |-- yes ===> recommendation is maintain
  945.          |-- no -- pine ----|
  946.                    needed   |-- no ===> do # 11
  947.  
  948.  
  949. Figure 2 - Decision tree used to represent a key.
  950.  
  951.  
  952.  
  953.  
  954.                            |-- yes ===> problem system is fuel
  955.           |-- yes -- gas --|
  956. car turns-|          smell |-- no ===> problem system is mechanical
  957. over      |
  958.           |-- no ===> problem system is electrical
  959.  
  960.  
  961.    _______________________                                     |-- no => recommend
  962.   | problem               |              |-- yes -- spark at --|         is
  963.   | system --- electrical |-- voltage    |          distibutor |         check points
  964.   |_______________________|   at battery-|                     |- yes => recommendation
  965.                                          |                               is find mechanic
  966.                                          |-- no ===> recommendation is
  967.                                                      replace battery
  968.  
  969.  
  970.  
  971.  
  972. Figure 3 - Decision trees breaking a problem into sub-problems.
  973.  
  974.  
  975.  
  976.  
  977. 1                                    4
  978. if car turns over is yes             if problem system is electrical
  979. and gas smell is yes                 and voltage at battery is yes
  980. then problem system is fuel .        and spark at distributor is no
  981.                                      then recommendation is check points .
  982. 2
  983. if car turns over is yes             5
  984. and gas smell is no                  if problem system is electrical
  985. then problem system is mechanical .  and voltage at battery is yes
  986.                                      and spark at distributor is yes
  987. 3                                    then recommendation is find mechanic .
  988. if car turns over is no
  989. then problem system is electrical .  6
  990.                                      if problem system is electrical
  991.                                      and voltage at battery is no
  992.                                      then recommendation is replace battery .
  993.  
  994.  
  995. Figure 4 - Rules to represent decision trees for auto repair.
  996.                                                                                     |-- yes ===> recommendation
  997.                                                                                     |            USE SEED TREE
  998.                                                                  |-- yes -- burning-|
  999.                                                                  |          planned |-- no ===> do # 17
  1000.                                              |-- yes -- 10/acre -|
  1001.                                              |          adequate |-- no ===> do # 17
  1002. _____________          |-- yes -- serotinous-|
  1003. | do #      |  pine    |          cones      |
  1004. | 11 -- yes |- desired-|                     |-- no ===> do # 17
  1005. |___________|          |
  1006.                        |-- no ===> recommendation is CONVERT
  1007.  
  1008.  
  1009. _____________
  1010. | do #      |          |-- shelterwood ===> recommendation is USE NATURAL SEEDING
  1011. | 17 -- yes |-- system-|
  1012. |___________|   used   |                         |-- yes ===> recommendation is PLANT
  1013.                        |-- clearcut -- improved -|
  1014.                                        stock     |             |-- yes ===> recommendation is
  1015.                                                  |-- good cone-|            SCATTER CONES
  1016.                                                      supply    |
  1017.                                                                |-- no ===> recommendation is
  1018.                                                                            DIRECT SEED
  1019.  
  1020.  
  1021.  
  1022. Figure 5 - Breaking the decision tree into manageable pieces.
  1023.  
  1024.  
  1025.  
  1026. 1                                    7
  1027. if minimum stocking is no            if do # 11 is yes
  1028. and pine needed is yes               and pine desired is yes                        
  1029. then recommendation is maintain .    and serotinous cones is yes                    
  1030.                                      and 10/acre adequate is no
  1031. 2                                    then do # 17 is yes .                          
  1032. if minimum stocking is yes                                                          
  1033. and pine needed is no                8                                              
  1034. then do # 11 is yes .                if do # 11 is yes                              
  1035.                                      and pine desired is yes                        
  1036. 3                                    and serotinous cones is no                     
  1037. if minimum stocking is no            then do # 17 is yes .                          
  1038. and diameter < 5 in. is no                                                          
  1039. and age is mature                    9                                              
  1040. then do # 11 is yes .                if do # 17 is yes                              
  1041.                                      and system used is shelterwood                 
  1042. 4                                    then recommendation is use natural seeding .        
  1043. if do # 11 is yes
  1044. and pine desired is no               10                                             
  1045. then recommendation is convert .     if do # 17 is yes                              
  1046.                                      and system used is clearcut
  1047. 5                                    and improved stock is yes                      
  1048. if do # 11 is yes                    then recommend is plant .                      
  1049. and pine desired is yes                                                             
  1050. and serotinous cones is yes          11
  1051. and 10/acre adequate is yes          if do # 17 is yes
  1052. and burning planned is yes           and system used is clearcut
  1053. then recommend is use seed tree .    and improved stock is no
  1054.                                      and good cone supply is yes
  1055. 6                                    then recommend is scatter cones .
  1056. if do # 11 is yes
  1057. and pine desired is yes              12
  1058. and serotinous cones is yes          if do # 17 is yes
  1059. and 10/acre adequate is yes          and system used is clearcut
  1060. and burning planned is no            and improved stock is no
  1061. then do # 17 is yes .                and good cone supply is no
  1062.                                      then recommend is direct seed .
  1063.  
  1064.  
  1065.  
  1066. Figure 6 - Rules that show the forest management problem broken
  1067.            into sub-problems.
  1068.  
  1069.  
  1070.  
  1071.            |-- yes ===> form complete   |-- new ==> call customer
  1072. all info --|                            |                                         use info
  1073. on form ?  |          New or existing --|                             |-- yes ==> to fill in
  1074.            |-- no --  customer ?        |               Is missing    |           form
  1075.                                         |-- existing -- info in the --|
  1076.                                                         file ?        |-- no ===> call
  1077.                                                                                   customer
  1078.  
  1079.  
  1080.              |--- < 250,000 ===> need financial statement
  1081. Amount of ---|
  1082. insurance    |--- >= 250,000 ===> no financial statement needed
  1083.  
  1084.  
  1085.  
  1086.                                              |--  35+  ===> schedule physical
  1087.                                 age of       |
  1088.              |--- >= 250000 --- applicant? --|-- 30 to 34 ==> fill out health form
  1089.              |                               |
  1090. amount of    |                               |-- < 30 ==> no medical information needed
  1091. insurance ---|
  1092.              |
  1093.              |                               |--  55+  ===> schedule physical
  1094.              |--- < 250000    -- age of      |
  1095.                                 applicant? --|-- 30 to 54 ==> fill out health form
  1096.                                              |
  1097.                                              |-- < 30 ==> no medical information needed
  1098.  
  1099.  
  1100.  
  1101. Figure 7 - Decision trees showing a knowledge base to help complete insurance
  1102.            application forms.
  1103.  
  1104.  
  1105. 1
  1106. if info complete is no
  1107. and new customer is yes
  1108. then display "Call the customer for the needed information."
  1109. and form complete is yes .
  1110.  
  1111. 2
  1112. if amount > 25000
  1113. then display "Send the customer a copy of financial form #432."
  1114. and financial checked is yes .
  1115.  
  1116. 3
  1117. if amount >= 25000
  1118. and age > 30
  1119. and age < 35
  1120. then display "Send applicant a statement of physical health form #67."
  1121. and medical info is yes .
  1122.  
  1123. 4
  1124. if form complete is yes
  1125. and financial checked is yes
  1126. and medical info is yes
  1127. then process application is done .
  1128.  
  1129.  
  1130. Figure 8 - Rules which show how separate decision trees can be chained
  1131.            together using "control attributes" and a control rule.
  1132. les which show how separat